package 代码随想录.数组.二分查找;

class Solution {


    public int search(int[] nums, int target) {
        int left = 0;
        int right = nums.length-1;
        while(left<=right) {
            int mid = left+((right-left)>>1);
            
            if(target == nums[mid]) {
                return mid;
            }else if(target < nums[mid]) {
                right = mid-1;
            }else {
                left = mid+1;
            }
        }
        return -1;
    }
    public static void main(String[] args) {
        
    }    
}
